package com.jse.script.groovy;

import groovy.lang.GroovyClassLoader;
import org.junit.Test;

import java.io.File;

/**
 * @author : zenghua
 * @version : v0.1 ClassLoaderTest.java
 * @since : 2017/9/14 12:49
 */
public class ClassLoaderTest {

	/**
	 * 将groovy文件实例化为class对象
	 */
	@Test
	public void instance() throws Exception {
		File groovyFile = new File("src/main/java/com/jse/script/groovy/ObjectFoo.groovy");
		//getClass().getClassLoader()
		GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
		Class fooClazz = groovyClassLoader.parseClass(groovyFile);
		System.out.println(fooClazz);
		System.out.println(((IObjectFoo)fooClazz.newInstance()).hello());
	}
}
